package design.factory.impl;

import design.factory.ICacheAdapter;
import design.master.IIR;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.concurrent.TimeUnit;

/**
 * @author: hero生仔
 */
public class IIRCacheAdapter implements ICacheAdapter {
    private Logger logger = LoggerFactory.getLogger(EGMCacheAdapter.class);
    private IIR iir = new IIR();

    @Override
    public String get(String key) {
        System.out.println("调用IIR的get方法，key为{}" + key);
        return iir.get(key);
    }

    @Override
    public void set(String key, String val) {
        logger.info("调用IIR的set方法，key为{}，value为{}", key, val);
        iir.set(key, val);
    }

    @Override
    public void set(String key, String val, long timeout, TimeUnit timeUnit) {
        logger.info("调用IIR的setExpire方法，key为{}，value为{}，timeout为{}，timeUnit为{}", key, val, timeout, timeUnit);
        iir.setExpire(key, val, timeout, timeUnit);
    }

    @Override
    public void del(String key) {
        logger.info("调用EGM的del方法，key为{}", key);
        iir.del(key);
    }
}
